
<template>
	<Button v-if="isButton" :type="data.theme" v-bind="data" @click="handleOperate">{{getCompatibleLabel}}</Button>
	<router-link
		v-else-if="data.to"
		:to="data.to"
		v-bind="data"
		data-vview-module="DropdownItem"
	>{{getCompatibleLabel}}</router-link>
	<a v-else-if="data.href" v-bind="data" data-vview-module="DropdownItem">{{getCompatibleLabel}}</a>
	<DropdownItem 
		v-else
		v-bind="data"
		data-vview-module="DropdownItem"
		@click="handleOperate"
	>{{getCompatibleLabel}}</DropdownItem>
</template>

<script>
export default {
	props: ['data', 'isButton'],
    created () {
        // console.log("operateLink", this.data, this.isButton);
    },
	computed: {
		//兼容老代码name属性
		getCompatibleLabel() {
			return this.data.langKey ? $ct(this.data.langKey, { defaultValue: this.data.name || this.data.label }) : (this.data.name || this.data.label)
		},
	},
	methods: {
		handleOperate() {
			this.$emit('on-click', this.data.params, this.data.operate, this.data.batch);
		},
	},
}
</script>